/**
 * @swagger
 * tags:
 *   name: Category
 *   description: 用户分类管理
 */
const express = require('express');
const router = express.Router();
const categoryController = require('../controllers/categoryController');
const auth = require('../middlewares/auth');
const admin = require('../middlewares/admin');

/**
 * @swagger
 * /api/category:
 *   get:
 *     summary: 获取所有用户分类
 *     tags: [Category]
 *     responses:
 *       200:
 *         description: 分类列表
 */
router.get('/', categoryController.list);

/**
 * @swagger
 * /api/category:
 *   post:
 *     summary: 新增分类
 *     tags: [Category]
 *     security:
 *       - bearerAuth: []
 *     requestBody:
 *       required: true
 *       content:
 *         application/json:
 *           schema:
 *             type: object
 *             properties:
 *               name:
 *                 type: string
 *     responses:
 *       200:
 *         description: 创建成功
 */
router.post('/', auth, admin, categoryController.create);

/**
 * @swagger
 * /api/category/{id}:
 *   put:
 *     summary: 修改分类
 *     tags: [Category]
 *     security:
 *       - bearerAuth: []
 *     parameters:
 *       - in: path
 *         name: id
 *         required: true
 *         schema:
 *           type: integer
 *     requestBody:
 *       required: true
 *       content:
 *         application/json:
 *           schema:
 *             type: object
 *             properties:
 *               name:
 *                 type: string
 *     responses:
 *       200:
 *         description: 修改成功
 */
router.put('/:id', auth, admin, categoryController.update);

/**
 * @swagger
 * /api/category/{id}:
 *   delete:
 *     summary: 删除分类
 *     tags: [Category]
 *     security:
 *       - bearerAuth: []
 *     parameters:
 *       - in: path
 *         name: id
 *         required: true
 *         schema:
 *           type: integer
 *     responses:
 *       200:
 *         description: 删除成功
 */
router.delete('/:id', auth, admin, categoryController.remove);

module.exports = router;
